#!/bin/bash

if [[ $# -eq 0 ]]; then
    echo "please input params"
    exit 0
fi

proc=${1%%/*}


function Run(){
    echo ">>>> running $proc "
    cd ${proc}/bin
    ./${proc} &
    cd - > /dev/null
    echo
}

function IsRunning(){
    local pid=`cat ${proc}/bin/${proc}.pid 2>/dev/null`
    if [[ ${pid} == "" ]];then
        Run
    else
        kill -9 ${pid}
        Run
    fi
}

IsRunning